<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../img/asset-favico.ico">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <link rel="stylesheet" href="../css/page-health-riskQuestion.css"/>
    <link rel="icon" href="../img/asset-favico.ico">
    <script src="../plugins/healthmobile.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/mint-ui@1/lib/style.css">
    <!-- 引入组件库 -->
    <link rel="stylesheet" href="../css/page-health-riskQuestion.css"/>
    <title>健康评估</title>
    <link rel="stylesheet" href="../css/page-health-risk.css"/>
</head>

<body data-spy="scroll" data-target="#myNavbar" data-offset="150">
<div class="app" id="app">
    <!-- 页面头部 -->
    <div class="top-header">
        <span class="f-left"><i class="icon-back" onclick="history.go(-1)"></i>返回</span>
        <span class="center">传智健康</span>
        <span class="f-right"><i class="icon-more"></i></span>
    </div>
    <!-- 页面内容 -->
    <div class="contentBox">
        <div class="bg-link">
            <a href="health-riskQuestion.html" class="link-page">
                <div class="risk-item item-one">
                    <div class="icon-text">
                        <i class="icon-data"></i>
                        <span>风险评估</span>
                    </div>
                </div>
            </a>
            <a href="health-physiqueAssessment.html" class="link-page">
                <div class="risk-item item-two">
                    <div class="icon-text">
                        <i class="icon-tizhi"></i>
                        <span>中医体质测评</span>
                    </div>
                </div>
            </a>
            <a href="health-riskQuestion.html" class="link-page">
                <div class="risk-item item-three">
                    <div class="icon-text">
                        <i class="icon-ask-cur"></i>
                        <span>心理问卷评估</span>
                    </div>
                </div>
            </a>
            <el-links target="_blank" @click="findReport()">
                <div class="risk-item item-two">
                    <div class="icon-text">
                        <i class="icon-tizhi"></i>
                        <span>查看体质</span>
                    </div>
                </div>
            </el-links>
            <el-links target="_blank" @click="findRiskReport()">
                <div class="risk-item item-two">
                    <div class="icon-text">
                        <i class="icon-tizhi"></i>
                        <span>查看体检风险报告</span>
                    </div>
                </div>
            </el-links>

            <!-- 查看体质报告标签弹层 -->
            <div class="add-form">
                <el-dialog title="查看报告" :visible.sync="dialogFormVisible4Edit" width="100%">
                    <template>

                        <el-form>
                            <el-row>
                                <el-col :span="6">
                                    <el-form-item label="名字">
                                        <el-input v-model="report.name" disabled="true"/>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="10" style="margin-left: 10px">
                                    <el-form-item label="档案号">
                                        <el-input v-model="report.fileId" disabled="true"/>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="6">
                                    <el-form-item label="性别">
                                        <el-input v-model="report.sex" disabled="true"/>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="6">
                                    <el-form-item label="年龄" style="margin-left: 10px">
                                        <el-input v-model="report.age" disabled="true"/>
                                    </el-form-item>
                                </el-col>
                            </el-row>

                            <el-row>
                                <el-col :span="8">
                                    <el-form-item label="阳虚体质">
                                        <el-input v-model="report.yangXuFen" disabled="true"/>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="阴虚体质" style="margin-left: 10px">
                                        <el-input v-model="report.yinXuFen" disabled="true"/>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="气虚体质" style="margin-left: 10px">
                                        <el-input v-model="report.qiXuFen" disabled="true"/>
                                    </el-form-item>
                                </el-col>
                            </el-row>

                            <el-row>
                                <el-col :span="8">
                                    <el-form-item label="痰湿体质">
                                        <el-input v-model="report.tanShiFen" disabled="true"/>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="湿热体质" style="margin-left: 10px">
                                        <el-input v-model="report.shiReFen" disabled="true"/>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="血瘀体质" style="margin-left: 10px">
                                        <el-input v-model="report.xueYuFen" disabled="true"/>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="8">
                                    <el-form-item label="特禀体质">
                                        <el-input v-model="report.teBingFen" disabled="true"/>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="气郁体质" style="margin-left: 10px">
                                        <el-input v-model="report.qiYuFen" disabled="true"/>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="8">
                                    <el-form-item label="平和体质" style="margin-left: 10px">
                                        <el-input v-model="report.pinHeFen" disabled="true"/>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                        </el-form>

                    </template>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible4Edit = false">关闭</el-button>
                    </div>
                </el-dialog>
            </div>

            <!-- 查看体检风评报告标签弹层 -->
            <div class="add-form">
                <el-dialog title="查看报告" :visible.sync="dialogFormVisible4Risk" width="100%">
                    <template>
                        <el-table :data="tableData">
                            <el-table-column property="name" label="评估人" width="80"></el-table-column>
                            <el-table-column property="checkItem" label="项目名称" width="100"></el-table-column>
                            <el-table-column property="result" label="结果"></el-table-column>
                            <el-table-column property="assessment" label="评估" width="60">
                                <template slot-scope="scope">
                                    <el-tag type="danger" v-if="scope.row.assessment=='高'">{{scope.row.assessment}}
                                    </el-tag>
                                    <el-tag type="success" v-if="scope.row.assessment=='正常'">{{scope.row.assessment}}
                                    </el-tag>
                                    <el-tag type="warning" v-if="scope.row.assessment=='低'">{{scope.row.assessment}}
                                    </el-tag>
                                </template>
                            </el-table-column>
                        </el-table>

                    </template>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible4Risk = false">关闭</el-button>
                    </div>
                </el-dialog>
            </div>

        </div>
    </div>
</div>

</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>

<script>
    var vue = new Vue({
        el: '#app',
        data: {
            activeName: 1,//添加/编辑窗口Tab标签名称
            pagination: {//分页相关属性
                currentPage: 1,
                pageSize: 10,
                total: 100,
                queryString: null,
            },
            dataList: [],//列表数据
            report: {}, //查询出的报告结果
            formData: {},//表单数据
            tableData: [],//新增和编辑表单中对应的检查项列表数据
            checkitemIds: [],//新增和编辑表单中检查项对应的复选框，基于双向绑定可以进行回显和数据提交
            dialogFormVisible: false,//控制添加窗口显示/隐藏
            dialogFormVisible4Edit: false,//控制编辑窗口显示/隐藏
            dialogFormVisible4Risk: false,//控制编辑窗口显示/隐藏

            rules: {//校验规则
                radio: [{required: true, message: '不能空选啊兄dei', trigger: 'change'}],
                fileId: [{required: true, message: '档案号不为空', trigger: 'blur'}],
                name: [{required: true, message: '名字不为空', trigger: 'blur'}],
                sex: [{required: true, message: '性别不为空', trigger: 'blur'}],
                age: [{required: true, message: '年龄不为空', trigger: 'blur'}],
            }
        },
        created() {
            this.findPage();
        },
        methods: {
            // 弹出查看报告窗口
            findRiskReport(row) {
                this.resetForm();

                axios.get("/riskAssessment/mobileFindRiskReportByFileNumber.do").then((res) => {
                    console.log(res.data.data);
                    if (res.data.flag) {
                        this.tableData = res.data.data;
                        console.log(this.tableData)
                    } else {
                        this.$message.error(res.message);
                    }
                });
                this.dialogFormVisible4Risk = true;

            },

            findByFileId() {
                axios.get("/member/findByFileId.do?id=" + this.formData.fileNumber)
                    .then(res => {
                        if (res.data.data.flag) {
                            if (res.data.data.data.sex === "1") {
                                res.data.data.data.sex = "男"
                            } else {
                                res.data.data.data.sex = '女';
                            }
                            this.formData = res.data.data.data;
                        } else {
                            console.log(res.data);
                            this.$message.error(res.data.data.message);
                        }
                        this.formData.age = res.age;
                    });
            },

            //添加
            handleAdd() {
                //
                if (this.formData.sex === '男') {
                    this.formData.sex = 1;
                } else {
                    this.formData.sex = 0;
                }
                this.formData.physiqueList = this.physiqueList;
                this.formData.fileId = this.formData.fileNumber;
                console.log(this.formData);
                axios.post("/physique/submitScore.do", this.formData).then((res) => {
                    //判断后台返回的flag值，true表示添加操作成功，false为添加操作失败
                    if (res.data.flag) {
                        this.$message.success(res.data.message);
                    } else {
                        this.$message.error(res.data.message);
                    }
                }).finally(() => {
                    //隐藏新增窗口
                    this.dialogFormVisible = false;
                    //调用分页查询方法
                    this.findPage();
                })
            },
            //分页查询
            findPage() {
                //分页查询的参数
                let temple = this.pagination.queryString;
                let param = {
                    currentPage: this.pagination.currentPage,
                    pageSize: this.pagination.pageSize,
                    queryString: (temple != null && temple === "") ? null : temple
                };
                if (param.queryString != null) {
                    param.currentPage = 1;
                }
                //异步进行分页查询
                axios.post("/physiqueAssessment/findPage.do", param).then((res) => {
                    //将分页查询的结果绑定到页面中
                    this.dataList = res.data.rows;
                    this.pagination.total = res.data.total;
                });
            },
            // 重置表单
            resetForm() {
                this.formData = {};
                this.physiqueList = []; //弹出层的体质列表 内含题干
                this.fileId = "";
                this.name = "";
                this.sex = null;
                this.age = null;
                this.activeName = 1;

            },
            // 弹出添加窗口
            handleCreate() {
                this.resetForm();
                this.findAll();
                this.dialogFormVisible = true;
            },

            // 弹出查看报告窗口
            findReport() {
                this.resetForm();
                //查询所有的检查项
                // this.findAll();
                //查询检查组信息
                axios.get("/physiqueAssessment/findPhysiqueAssessmentByPhoNumber.do").then((res) => {
                    if (res.data.flag) {
                        if (res.data.data.sex === 1) {
                            res.data.data.sex = '男';
                        } else {
                            res.data.data.sex = '女';
                        }
                        this.report = res.data.data;
                    } else {
                        this.$message.error(res.message);
                    }
                });
                this.dialogFormVisible4Edit = true;

            },

            findAll() {
                //查询全部体质并赋值到tab pane列表
                axios.get("/physique/findAll.do").then((res) => {
                    if (res.data.flag) {
                        this.physiqueList = res.data.data;
                    } else {
                        this.$message.error(res.data.message);
                    }
                });
            },

            //切换页码
            handleCurrentChange(currentPage) {
                //使用临时变量存储搜索框中数据
                var queryString = this.pagination.queryString;
                //修改搜索框中的数据为null
                this.pagination.queryString = null;
                //修改分页查询页码为选中页码
                this.pagination.currentPage = currentPage;
                //调用分页查询
                this.findPage();
                //将搜索框中数据重写回搜索框
                this.pagination.queryString = queryString;
            },
            // 删除
            handleDelete(row) {
                this.$confirm('此操作将删除条数据, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    axios.get("/physiqueAssessment/delete/" + row.id + ".do").then((res) => {
                        if (res.data.flag) {
                            this.$message.success(res.data.message);
                        } else {
                            this.$message.error(res.data.message);
                            return false;
                        }
                    }).finally(() => {
                            this.findPage();
                        }
                    );
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '操作已取消'
                    });
                });
            }
        }
    })
</script>
</html>